<template>
    <div>
        <table class="table table-bordered">
                <tr>
                    <td>等级名称</td>
                    <td>
                        <input type="text" v-model="queryinfo.LevelName">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="添加" @click="addlevel">
                    </td>
                </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive} from 'vue'
import{useRouter} from 'vue-router'
import axios from 'axios';

let router=useRouter();

let queryinfo=reactive({
    LevelName:'',
})

const addlevel=()=>{
    if(queryinfo.LevelName==""){
        alert("等级名称不能为空");
        return;
    }


    axios({
        method:'post',
        url:'/api/Member/AddLevel',
        data:queryinfo,


    })
    .then(res=>{
        console.log(res);
        if(res.data>0){
            alert("添加成功");

            router.push('/levelshow');
        }
        else{
            alert("添加失败");
            return;
        }
    })
    .catch(err=>{
        console.log(err);
    })
}





</script>

<style scoped>

</style>